import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
	{
		path: '/',
		name: '前台首页',
		component: () => import('@/views/ServiceCounter/Home.vue'),
		redirect:'/EntryPage/EntryPage',
		children:[
			{
				path: '/EntryPage/EntryPage',
				name: '首页',
				meta:{title:"拍卖网"},
				component: () => import('@/views/ServiceCounter/EntryPage/EntryPage.vue'),
				meta: {
					requireAuth: true
				}
			},
			{
				path: '/ListItem/ListItem',
				name: '列表',
				component: () => import('@/views/ServiceCounter/ListItem/ListItem.vue'),
				meta: {
					requireAuth: true
				}
			},
			{
				path: '/ListItem/Particulars',
				name: '列表详情',
				component: () => import('@/views/ServiceCounter/ListItem/Particulars/Particulars.vue'),
				meta: {
					requireAuth: true
				}
			},
			{
				path: '/ListItem/ParticularIng',
				name: '拍卖列表详情',
				meta:{title:"拍卖大厅"},
				component: () => import('@/views/ServiceCounter/ListItem/ParticularIng/ParticularIng.vue'),
				meta: {
					requireAuth: true
				}
			},
			{
				path: '/Center/Index',
				name: '个人中心',
				component: () => import('@/views/ServiceCounter/Center/Index/Index.vue'),
				meta: {
					requireAuth: true
				}
			},
		]
	},
	{
		path: '/Home/Login',
		name: '后台登录',
		component: () => import('@/views/Login.vue')
	},
	{
		path: '/User/Login',
		name: '前台登录',
		component: () => import('@/views/ServiceCounter/Login/Login.vue')
	},
	{
		path: '/Home',
		name: '首页',
		component: () => import('../views/Home/Home.vue'),
		children: [
			{
				path: '/Console/index',
				name: '权限管理',
				component: () => import('../views/Home/Console/index.vue'),
				meta: {
					requireAuth: true
				}
			},
			{
				path: '/Personnel/index',
				name: '管理员管理',
				component: () => import('../views/Home/Personnel/index.vue'),
				meta: {
					requireAuth: true
				}
			},
			{
				path: '/Personnel/User',
				name: '用户名单',
				component: () => import('../views/Home/Personnel/User.vue'),
				meta: {
					requireAuth: true
				}
			},
			{
				path: '/Auction/AuctionItem',
				name: '拍卖品列表',
				component: () => import('../views/Home/Auction/AuctionItem.vue'),
				meta: {
					requireAuth: true
				}
			},
			{
				path: '/Auction/AuctionItem/List',
				name: '拍卖品组列表',
				component: () => import('../views/Home/Auction/AuctionItemList/List.vue'),
				meta: {
					requireAuth: true
				}
			},
			{
				path: '/Auction/AuctionSpell',
				name: '拍卖品订单',
				component: () => import('../views/Home/Auction/AuctionSpell.vue'),
				meta: {
					requireAuth: true
				}
			},
			{
				path: '/System/Config',
				name: '系统设置',
				component: () => import('../views/Home/System/Config.vue'),
				meta: {
					requireAuth: true
				}
			},
			{
				path: '/System/PersonalCenter',
				name: '个人中心',
				component: () => import('../views/Home/System/PersonalCenter.vue'),
				meta: {
					requireAuth: true
				}
			},
		]
	},
]

const router = new VueRouter({
	// mode: 'history',
	base: process.env.BASE_URL,
	routes
})

router.beforeEach((to,from,next)=>{//beforeEach是router的钩子函数，在进入路由前执行
	// console.log(to);
    if(to.name){//判断是否有标题
        document.title = to.name
    }
    next()  //执行进入路由，如果不写就不会进入目标页
})

export default router
